package com.gxa.admin.recycling.service.impl;

import com.gxa.admin.recycling.mapper.GoodsOrderMapper;
import com.gxa.admin.recycling.service.GoodsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("goodsOrderService")
public class GoodsOrderServiceImpl implements GoodsOrderService {
    @Autowired
    GoodsOrderMapper goodsOrderMapper;
    @Override
    public List<Map> findAllByPage(Long id, String provinces, String comityName, String userName, String state, String exchangetime, Integer page, Integer size) {
        if (provinces!=null && provinces !=""){
            provinces = "%"+provinces+"%";
        }
        if (comityName!=null && comityName !=""){
            comityName = "%"+comityName+"%";
        }
        if (userName!=null && userName !=""){
            userName = "%"+userName+"%";
        }
        if (exchangetime!=null && exchangetime !=""){
            exchangetime = "%"+exchangetime+"%";
        }

        return goodsOrderMapper.findAllByPage(id, provinces, comityName, userName, state, exchangetime, (page-1)*size, size);
    }

    @Override
    public Map findById(Long id) {
        return goodsOrderMapper.findById(id);
    }

    @Override
    public List<Map<String, Object>> getAllCount(String name, String start, String end, String from, String to) {
        List<Map<String, Object>> allCount = goodsOrderMapper.getAllCount(name, start, end, from, to);
        return allCount;
    }
}
